/*
 * @Author: your name
 * @Date: 2022-02-25 15:07:26
 * @LastEditTime: 2022-02-25 15:29:52
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \briup-study\JS\7-类型转换.js
 */
//1、将其他数据类型转化为string类型，tostring是内置函数直接调用
var a=1;
console.log(a.toString(),typeof(a.toString()));
//var b=hello + '';  报错
var b=2 + '';
console.log(b,typeof(b));
var c=false + '';
console.log(c,typeof c);
//2.boolean
    //1\Boolean()函数进行转换
    var f='';
    var e=123;
    var d ='hello';
    //console.log(d.Boolean(),typeof(d.Boolean()));
    console.log(Boolean(d),typeof(Boolean(d)));
    console.log(Boolean(e),typeof(Boolean(e)));
    console.log(Boolean(f),typeof(Boolean(f)));

    //!!变量将其他数据类型转换为布尔类型
    var a='false'
    console.log(!!a,typeof(!!a)); //取反取反相对于没变 不是空字符，并将字符串变为布尔类型

    var a=12
    console.log(!!a,typeof(!!a),'1111');
//number 类型 将其他数据类型转换为number类型
    //1.NUMBER ()函数进行转换
    var a='hello';//false --0 true ---1  null----0  undefine ----NaN
    console.log(Number(a),typeof(Number(a)),'number类型转换2');

    //2.parseint ()  paresFloat
    var a='12.3';
    console.log(parseInt(a),typeof(parseInt(a)),'number类型转换3');